//
//  WXSanFangViewController.m
//  Big Show
//
//  Created by dlios on 15-5-15.
//  Copyright (c) 2015年 Big_Q. All rights reserved.
//

#import "WXSanFangViewController.h"
#import "XHNetworkHandle.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 667

@interface WXSanFangViewController ()

@property (nonatomic, retain) NSMutableArray *mArr;

@property (nonatomic, retain) NSMutableDictionary *mDic;

@property (nonatomic, retain) NSString *path;

@property (nonatomic, retain) NSArray *urlArr;

@property (nonatomic, retain) NSArray *urlllllArr;

@property (nonatomic, retain) NSArray *titleArr;

@end

@implementation WXSanFangViewController



- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.translucent = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"首页";
//    self.navigationController.navigationBar.translucent = NO;
//    self.automaticallyAdjustsScrollViewInsets = NO;
    self.urlArr = @[@"http://app.api.repaiapp.com/sx/songshijie/man/bamei/qu.php", @"http://app.api.repaiapp.com/sx/songshijie/man/chase_skill/qu.php", @"http://app.api.repaiapp.com/sx/songshijie/man/skin/qu.php"];
    
    self.urlllllArr = @[@"bamei", @"chase_skill", @"skin"];
    
    self.titleArr = @[@"发型", @"外套", @"恋爱", @"时尚", @"星座", @"衬衫", @"情感故事", @"夏季着装", @"把妹", @"搭讪技巧", @"男士护肤"];
    
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@" Big Show"];
    [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
    self.indexLabel.attributedText = str;
    
    
    
    
    
    [self creat];
    [self getDataaaa];

 }

-(void) creat
{
    // 背景图片
    UIImage *image = [UIImage imageNamed:@"u=2916742164,3184761356&fm=21&gp=0.jpg"];
    self.imageV = [[UIImageView alloc] initWithImage:image];
    self.imageV.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    //----------------------第三方-------------------------//
    //    签订第三方协议
    self.sliderImageView.delegate = self;
    //放第三方的效果图片
    for (int i = 0; i < 12; i++) {
        NSString *imageName = [NSString stringWithFormat:@"%d.jpg", i];
        UIImage *image = [UIImage imageNamed:imageName];
        [self.sliderImageView addImage:image];
    }
    //第三方UIView
    [self.sliderImageView setImageShadowsWtihDirectionX:2 Y:2 Alpha:0.7];
    [self.sliderImageView reLoadUIview];
    
    
    self.imageV.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    [self.view addSubview:self.imageV];
}

-(id)init
{
    
    self = [super init];
    if (self) {
        //第三方适配
        CGFloat width = [UIScreen mainScreen].bounds.size.width;
        CGFloat height = [UIScreen mainScreen].bounds.size.height;
        CGRect rect = {{50*WIDTH,96*HEIGHT},{width-150*WIDTH,height-350*HEIGHT}};
        self.sliderImageView = [[SlideImageView alloc] initWithFrame:rect ZMarginValue:6 XMarginValue:10 AngleValue:0.3 Alpha:1000];
        self.sliderImageView.borderColor = [UIColor whiteColor];
        self.sliderImageView.delegate = self;
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
        [self.view bringSubviewToFront:self.clickLabel];
        
    }
    return self;
}



// 好删

- (void) getDataaaa
{
    
    [XHNetworkHandle getDataWithURL:@"http://a1.go2yd.com/Website/user/get-info?appid=dress&cv=1.1.1&distribution=com.apple.appstore&net=wifi&platform=0&version=010904" cookie:@"JSESSIONID=7tFm_0dR9sFG5Bm0IAnlqw" completion:^(id result) {
        
        self.mArr = [result objectForKey:@"user_channels"];
    }];
}





- (void)loadView
{
    [super loadView];
    [self.view addSubview:self.sliderImageView];
    self.indexLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, self.sliderImageView.frame.origin.y + self.sliderImageView.frame.size.height + 30, 200, 35)];
    self.indexLabel.font = [UIFont systemFontOfSize:20.f];
    self.indexLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:self.indexLabel];
    
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)SlideImageViewDidClickWithIndex:(int)index
{
     XHDetailViewController *detail = [[XHDetailViewController alloc] init];//属性传值2
    WXBaMeiDaShanViewController *baMeiDeatail = [[WXBaMeiDaShanViewController alloc] init];
    
    // 进入动画
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    animation.type = @"moviID";
    [animation setSubtype:kCATransitionFromRight];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
    
    if (index == 0) {
        
    } else if(index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 6 ||index == 7 || index == 8){
        // 属性传值3

        detail.myTitle = [_titleArr objectAtIndex:index - 1];
        detail.docid = [[_mArr objectAtIndex:index - 1] objectForKey:@"channel_id"];

    detail.docid = [[_mArr objectAtIndex:index - 1] objectForKey:@"channel_id"];

    [self.navigationController.view.layer addAnimation:animation forKey:nil];
    [self.navigationController pushViewController:detail animated:YES];
    }else{
        
        
        baMeiDeatail.myTitle = [_titleArr objectAtIndex:index - 1];
        baMeiDeatail.urll = [_urlllllArr objectAtIndex:index - 9];
        baMeiDeatail.url = [_urlArr objectAtIndex:index - 9];
        
        [self.navigationController.view.layer addAnimation:animation forKey:nil];
        [self.navigationController pushViewController:baMeiDeatail animated:YES];
    }
    
    
}


-(void)SlideImageViewDidEndScorllWithIndex:(int)index
{
    if (index == 0) {
        
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@" Big Show"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }
    if (index == 1) {
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"发型提升魅力"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 2){
         NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"外套展现逼格"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 3){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"恋爱寻找自我"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 4){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"引领时尚潮流"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(2, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 5){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"星座道破内在"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 6){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"衬衫彰显个性"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 7){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"情感诉说真爱"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 8){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"寻找夏季风潮"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(2, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 9){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"爱要敢于追求"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 1)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 10){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"从初识到相知"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(0, 1)];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(3, 1)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];

        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }else if (index == 11){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"男士也要保养"];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:23.0] range:NSMakeRange(4, 2)];
        self.indexLabel.attributedText = str;
        self.indexLabel.textColor = [UIColor whiteColor];
        [self.view bringSubviewToFront:self.sliderImageView];
        [self.view bringSubviewToFront:self.indexLabel];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
